package vn.com.mybudget.bo;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.google.appengine.api.users.User;

import vn.com.mybudget.da.gae.PMF;
import vn.com.mybudget.da.inf.IAccountDA;
import vn.com.mybudget.entities.Account;

public class AccountBO extends BOBase<IAccountDA>{
	public AccountBO() {
		super("Account");
	}
    public Account AddAccount(Account acc){
    	return this.getDAInstance().AddObject(acc);
    }
	public Account getAccountByEmail(User user) {
		Account currentAccount;
		currentAccount= this.getDAInstance().getAccountByEmail(user.getEmail());
		if (currentAccount == null){
			Calendar cal = Calendar.getInstance();
			currentAccount = new Account();
			currentAccount.setEmail(user.getEmail());
			currentAccount.setJoineddate(cal.getTime());			
			currentAccount=this.AddAccount(currentAccount);
		}
		return currentAccount;
	}
	public boolean UpdateAccount(Account currentUser) {
		return PMF.save(currentUser) == null;
	}
}
